package com.foreveredu.propms.domain;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

/**
 * Description:<br/>
 * 领域模型：小区类，一个物业服务处可包含多个小区<br/>
 * Date:<br/>
 * 2013/3/2<br/>
 * 
 * @author hushigang
 */

@Entity
@Table(name = "T_SubDistrict")
public class SubDistrict implements Serializable {
	private static final long serialVersionUID = 1L;
	private int id;
	private String subDistrictId;// 小区编号
	private String name;// 小区名称
	private String address;// 小区地址
	private String takeTime;// 接管年份
	private District district;// 所属物业服务处
	private Set<Building> buildings = new HashSet<Building>();//小区包含的所有楼栋，（双向一对多关系）

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	@Column
	public String getSubDistrictId() {
		return subDistrictId;
	}

	public void setSubDistrictId(String subDistrictId) {
		this.subDistrictId = subDistrictId;
	}

	@Column
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column
	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}
	
	@Column
	public String getTakeTime() {
		return takeTime;
	}

	public void setTakeTime(String takeTime) {
		this.takeTime = takeTime;
	}

	@ManyToOne
	@JoinColumn(name = "district_id")
	public District getDistrict() {
		return district;
	}

	public void setDistrict(District district) {
		this.district = district;
	}

	@OneToMany(mappedBy="subDistrict")
	@OrderBy(value="id ASC")
	public Set<Building> getBuildings() {
		return buildings;
	}

	public void setBuildings(Set<Building> buildings) {
		this.buildings = buildings;
	}
}
